//
//  XYSecondPictureView.m
//  新项目
//
//  Created by xmy on 2017/2/27.
//  Copyright © 2017年 xmy. All rights reserved.
//

#import "XYSecondPictureView.h"

@implementation XYSecondPictureView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    //头像
    UIImageView *iconImageView =[[UIImageView alloc]init];
    iconImageView.layer.masksToBounds = YES;
    iconImageView.layer.cornerRadius = 20;
    iconImageView.image = [UIImage imageNamed:@"avatar_default_small"];
    
    //昵称
    UILabel *nameLable = [[UILabel alloc]init];
    nameLable.font = [UIFont systemFontOfSize:16];
    nameLable.text = @"笑笑";
    
    //会员图标
    UIImageView * memberIconImage = [[UIImageView alloc]init];
    memberIconImage.image = [UIImage imageNamed:@"avatar_vip"];
    
    //关注
    UIButton *recommentButton = [[UIButton alloc]init];
    [recommentButton setTitle:@"+ 关注" forState:UIControlStateNormal];
    recommentButton.titleLabel.font = [UIFont systemFontOfSize:16];
//    [recommentButton setTintColor:[UIColor blueColor]];
//    recommentButton.titleLabel.textColor = [UIColor blackColor];
    [recommentButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];

    //左侧照片
    UIImageView * leftImageView = [[UIImageView alloc]init];
    [leftImageView setImage:[UIImage imageNamed:@"guideImage2"]];
    
    //右侧照片
    UIImageView * rightImageView = [[UIImageView alloc]init];
    [rightImageView setImage:[UIImage imageNamed:@"guideImage2"]];
    
    //内容
    UILabel *contentLable = [[UILabel alloc]init];
    contentLable.text = @"哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈";
    contentLable.numberOfLines = 2;
    
    //标签
    UILabel *declareLable = [[UILabel alloc]init];
    declareLable.text = @"美容";
    declareLable.font = [UIFont systemFontOfSize:12];
    
    
    //小红点
    UIImageView * hotImageView = [[UIImageView alloc]init];
    hotImageView.image = [UIImage imageNamed:@"index_quanguoredian_press"];
    
    [self addSubview:iconImageView];
    [self addSubview:nameLable];
    [self addSubview:memberIconImage];
    [self addSubview:recommentButton];
    [self addSubview:leftImageView];
    [self addSubview:rightImageView];
    [self addSubview:contentLable];
    [self addSubview:declareLable];
    [self addSubview:hotImageView];
    
    
    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self).offset(8);
        make.width.height.offset(40);
    }];
    
    [nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconImageView.mas_right).offset(8);
        make.centerY.equalTo(iconImageView);
    }];
    [memberIconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nameLable.mas_right).offset(8);
        make.centerY.equalTo(nameLable);
        make.width.height.offset(14);
    }];
    [recommentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-8);
        make.centerY.equalTo(iconImageView);
    }];
    [leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(iconImageView.mas_bottom).offset(5);
        make.left.equalTo(iconImageView);
        make.height.offset(([UIScreen mainScreen].bounds.size.width - 24) * 0.5);
    }];
    [rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(leftImageView);
        make.right.equalTo(recommentButton);
        make.left.equalTo(leftImageView.mas_right).offset(5);
        make.width.height.equalTo(leftImageView);
    }];
    [contentLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(leftImageView.mas_bottom).offset(12);
        make.right.equalTo(rightImageView);
        make.left.equalTo(leftImageView);
    }];
    [hotImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(contentLable.mas_bottom).offset(10);
        make.left.equalTo(contentLable);
        make.width.height.offset(12);
    }];
    [declareLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(hotImageView);
        make.left.equalTo(hotImageView.mas_right).offset(8);
    }];
    
    
}

//关注
- (void)btnClick{
    
    NSLog(@"点击了关注");
}

//+ (instancetype)secondView;{
//    
//     return [[[NSBundle mainBundle] loadNibNamed:@"XYSecondPictureView" owner:nil options:nil] lastObject];
//    
//}

@end
